package Exercise;
import java.awt.Button;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.util.Iterator;

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;

public class MyUitl {
	public static JMenuBar createMenu(String str_menu[],String str_menuitem[][])
	{
		JMenuBar bar = new JMenuBar();
		JMenu menu = null;
		JMenuItem menuitem = null;
		for (int i = 0; i < str_menu.length; i++) {
			menu = new JMenu(str_menu[i]);
			for (int j = 0; j < str_menuitem[i].length; j++) {
				menuitem = new JMenuItem(str_menuitem[i][j]);
				menu.add(menuitem);
			}
			bar.add(menu);
		}
		return bar;
	}
	
	public static JPanel createButtonPanel(String str_btn[],int row,int col)
	{
		JPanel p = null;
		Button btn = null;
		if(str_btn!=null)
		{
			p = new JPanel();
			p.setLayout(new GridLayout(row,col,2,2));
			for (int i = 0; i < str_btn.length; i++) {
				btn = new Button(str_btn[i]);
				p.add(btn);
			}
		}
		return p;
	}
}
